const express = require('express');
const router = express.Router();
const { success, failure } = require('../utils/responses');
const { mailProducer } = require('../utils/rabbit-mq');
const logger = require('../utils/logger');

/**
 * 阿里云 OSS 客户端上传
 * POST /uploads/mail
 */
router.post('/', async (req, res) => {
  try {
    const { nickname, email } = req.body;
    // 发送邮件
    await mailProducer({ nickname, email });

    success(res, '邮件发送成功');
  } catch (error) {
    logger.error(error);
    failure(res, error);
  }
});

module.exports = router;
